package 剑指offer.Month7_07.day12;

public class 删除链表的节点 {
    public ListNode deleteNode (ListNode head, int val) {
        // write code here
        ListNode node = new ListNode(-1);
        node.next = head;
        ListNode cur = node;
        ListNode tmp = null;
        while (cur.next != null){
            if(cur.next.val == val){
                tmp = cur.next;
                cur.next = cur.next.next;
                break;
            }
            cur = cur.next;
        }
        tmp.next = null;
        return node.next;
    }
}
